package com.douqu.game.core.config.challenge;

import com.douqu.game.core.config.common.GoodsData;
import com.douqu.game.core.entity.GameObject;
import com.douqu.game.core.factory.DataFactory;
import com.douqu.game.core.protobuf.SGCommonProto;
import com.douqu.game.core.util.LoadUtils;
import com.douqu.game.core.util.LogUtils;

import java.util.Arrays;

/**
 * @author wangzhenfei
 *         2017-10-11 14:07
 *         竞技场积分奖励配置
 */
public class OfficialIntegralConfig extends GameObject {

    /** 积分 **/
    public int integral;
    /** 奖励组 */
    public GoodsData[] reward;

    @Override
    public boolean check()
    {
        if(reward == null)
        {
            LogUtils.error("OfficialIntegral check reward is null -> id:" + id + " name:" + name);
            return false;
        }
        return true;
    }



    @Override
    public boolean setVariable(String key, String value)
    {
        if("reward".equals(key))
        {
            reward = LoadUtils.loadGoodDataToArray(key, value);
            return LoadUtils.checkGoods(reward, this.getClass(), key, id);
        }
        else
            return super.setVariable(key, value);
    }

    @Override
    public String toString() {
        return "OfficialIntegral{" +
                "integral=" + integral +
                ", reward=" + Arrays.toString(reward) +
                "} " + super.toString();
    }
}
